﻿using ControleRepresentante.Data.Catalogs;
using ControleRepresentante.Data.Helpers;

namespace ControleRepresentante.Data.CatalogSteps
{
    internal class CreateClienteCatalogStep : CatalogStepBase<ControleRepresentanteCatalogStepTypes>
    {
        protected override ControleRepresentanteCatalogStepTypes CatalogStepType
        {
            get { return ControleRepresentanteCatalogStepTypes.CreateCliente; }
        }

        public override void Execute(IDataAccess dataAccess)
        {
            CatalogStepHelper catalogStepHelper = new CatalogStepHelper(dataAccess);

            catalogStepHelper
                .CreateTable("Cliente", false, "UsuariosHolderId")
                    .AddForeignKey("UsuariosHolderId", "UsuariosHolder", "DetailsHolderId")
                    .AddColumn("VendedorId", ColumnType.Guid, true, false)
                    .AddForeignKey("VendedorId", "Vendedor", "UsuariosHolderId")
                    .AddColumn("EnderecoEntregaId", ColumnType.Guid, true, false)
                    .AddForeignKey("EnderecoEntregaId", "Endereco")
                    .AddColumn("EnderecoCobrancaId", ColumnType.Guid, true, false)
                    .AddForeignKey("EnderecoCobrancaId", "Endereco")
                    .AddColumn("CNPJ", ColumnType.ShortString, true, false)
                    .AddColumn("InscricaoEstadual", ColumnType.ShortString, true, false)
                    .AddColumn("RazaoSocial", ColumnType.ShortString, false, false)
                    .AddColumn("NomeFantasia", ColumnType.ShortString, false, false);

            catalogStepHelper
                .CreateTable("ClienteJolitex")
                    .AddColumn("Codigo", ColumnType.ShortNumeric, true, false)
                    .AddColumn("Regiao", ColumnType.ShortNumeric, true, false);
        }
    }
}